package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.DynamicSecondaryReview;
import cn.wolfcode.trip.base.mapper.DynamicSecondaryReviewMapper;
import cn.wolfcode.trip.base.query.DynamicSecondaryReviewQueryObject;
import cn.wolfcode.trip.base.service.IDynamicSecondaryReviewService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

@Service
public class DynamicSecondaryReviewServiceImpl implements IDynamicSecondaryReviewService {
    @Autowired
    private DynamicSecondaryReviewMapper dynamicSecondaryReviewMapper;

    /**
     * 返回一页动态里面所有的回复评论
     * @return
     */
    public List getListByDynamicIds(Long[] ids) {
        ArrayList list = new ArrayList();
        if (ids!=null) {
            for (Long id : ids) {
                DynamicSecondaryReviewQueryObject qo = new DynamicSecondaryReviewQueryObject();
                qo.setDynamicId(id);
                List dys = dynamicSecondaryReviewMapper.selectAllReply(qo);
                if(dys.size()!=0){
                    list.add(dys);
                }
            }
        }
        return list;
    }

    /**
     * 为动态增加一条评论
     * @param dynamicSecondaryReview
     */
    public void save(DynamicSecondaryReview dynamicSecondaryReview) {
        dynamicSecondaryReviewMapper.insert(dynamicSecondaryReview);
    }
}